package javaCode.chapter07.Homework.homework08;

/*
要求：
1、在上面类的基础上扩展 新类CheckingAccount 对每次存款和取款都收取 1美元的手续费
2、扩展前一个练习的BankAccount类 ，新类SavingsAccount 每个月都有利息产生
(earnMonthlyInterest方法被调用)，并且有每三次免手续费的存款或取款。在earnMonthlyInterest方法中重置交易计数
3、体会重写的好处
 */
public class Homework08 {
    public static void main(String[] args) {

//        CheckingAccount checkingAccount = new CheckingAccount(1000);
//        checkingAccount.deposit(1000); //1000 + 1000 -1
//        checkingAccount.withdraw(500); //2000 - 500 - 1
//        System.out.println(checkingAccount.getBalance());

        SavingsAccount savingsAccount = new SavingsAccount(1000);
        savingsAccount.deposit(100);
        savingsAccount.deposit(100);
        savingsAccount.deposit(100);
        System.out.println(savingsAccount.getBalance()); //1300
        savingsAccount.deposit(100);
        System.out.println(savingsAccount.getBalance()); //1300 + 100 - 1

        //月初，利息  定时器自动调用一下
        savingsAccount.earnMonthlyInterest();
        System.out.println(savingsAccount.getBalance()); // 1399 * 0.01 = 1412.99
        savingsAccount.deposit(100);
        System.out.println(savingsAccount.getBalance());
    }
}
